let search_list = document.getElementById("search_list");
// console.log("111");
function jsonpCallback(data) {
    let { g } = data;
    g = g || [];
    search_list.innerHTML = g.map(item => `<li>${item.q}</li>`).join("")
}

// jsonp 事件驱动 : 
let search = document.getElementById("search_keyword");
search.addEventListener("input", () => {
    let script = document.createElement("script");
    script.src = `https://www.baidu.com/sugrec?prod=pc&from=pc_web&wd=${(search_keyword).value}&cb=jsonpCallback`;
    console.log(script);
    document.body.appendChild(script);
    script.remove(); 
})

// document.getElementById("search_keyword").addEventListener("click" , ()=>{
//     search_list.setAttribute("style" , "display:block")
// })